package com.xuzao.developer.controller;

import com.github.pagehelper.PageInfo;
import com.xuzao.developer.base.model.SysResource;
import com.xuzao.developer.base.model.SysUser;
import com.xuzao.developer.dao.SysUserDao;
import com.xuzao.developer.vo.BaseResultVo;
import com.xuzao.developer.tools.entity.Pager;
import com.xuzao.developer.dto.SysResourceDTO;
import com.xuzao.developer.service.SysResourceService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

/**
 * @description 
 * @author xuzao
 * @date 2019-09-19 09:38:12
 **/
@Controller
@RequestMapping("/sysResource/")
public class SysResourceController{

	@Resource
	private SysResourceService sysResourceService;
	@Resource
	private SysUserDao sysUserDao;

	@RequestMapping("queryList")
	public String queryList(SysResourceDTO dto, Pager pager, Model model) {
		String str = sysResourceService.list(dto,pager);
		model.addAttribute("str",str);
		model.addAttribute("userInfo",sysUserDao.selectById(dto.getUserId()));
		return "/sys_resource/sys_resource_list";
	}

	@RequestMapping("addSysResource")
	public BaseResultVo addSysResource(SysResourceDTO dto){
		return sysResourceService.insert(dto);
	}

	@RequestMapping("updateSysResource")
	public BaseResultVo updateSysResource(SysResourceDTO dto){
		return sysResourceService.update(dto);
	}

	@RequestMapping("getSysResource")
	public BaseResultVo getSysResource(SysResourceDTO dto){
		return sysResourceService.get(dto);
	}

}